Skip to content

feat: add configurable default theme option#16

Merged
selimacerbas merged 2 commits into
selimacerbas:mainfrom
gogongxt:feat/theme-config
May 24, 2026
Merged

feat: add configurable default theme option#16
selimacerbas merged 2 commits into
selimacerbas:mainfrom
gogongxt:feat/theme-config

Conversation

@gogongxt
Copy link
Copy Markdown
Contributor

Summary

  • Add theme config option ("dark" or "light") to set the initial preview page theme, defaulting to "dark" for backwards compatibility
  • Previously the theme was hardcoded to "dark" in both the HTML template (data-theme) and JavaScript (currentTheme / applyTheme('dark'))
  • Uses the same __PLACEHOLDER__ + gsub pattern as bottom_padding

Changes

  • assets/index.html: Replace hardcoded data-theme="dark" with data-theme="__THEME__", read initial theme from dataset.theme in JS, and use currentTheme in boot instead of hardcoded 'dark'
  • lua/markdown_preview/init.lua: Add theme = "dark" to config, add __THEME__ gsub in write_index()
  • README.md: Document theme option in Quick start and Configuration sections

Usage

require("markdown_preview").setup({ theme = "light" })

@selimacerbas
Copy link
Copy Markdown
Owner

Hey @gogongxt, clean PR. The placeholder pattern is right and the "dark" default keeps things backwards compatible. One small ask before merging.

Could you rename theme to default_theme? Two reasons:

  1. The sun/moon toggle in the browser still works after page load, so theme is a bit misleading. It's really the initial theme.
  2. Keeps the theme name free for a richer config later (custom palette, named themes, etc.) without a breaking rename.

If you push that rename plus a one-line README touch-up, I'll merge. Closes #19.

@gogongxt
Copy link
Copy Markdown
Contributor Author

Done.

gogongxt and others added 2 commits May 24, 2026 11:48
Allow users to set the initial preview theme ("dark" or "light") via
the `theme` config option, defaulting to "dark" for backwards
compatibility. Previously the theme was hardcoded to dark in both
the HTML template and JavaScript.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants